package com.nsapi.niceschoolapi.service.impl;

import com.nsapi.niceschoolapi.entity.ClassinfoDB;
import com.nsapi.niceschoolapi.entity.DropoutVO;
import com.nsapi.niceschoolapi.entity.StudentDB;
import com.nsapi.niceschoolapi.entity.StudentVO;
import com.nsapi.niceschoolapi.mapper.AddStudentMapper;
import com.nsapi.niceschoolapi.mapper.StudentMapper;
import com.nsapi.niceschoolapi.service.StudentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service("studentService")
public class StudentServiceImpl implements StudentService {
    @Resource
    private AddStudentMapper addStudentMapper;

    @Resource
    private StudentMapper studentMapper;


    @Override   //根据前台传来信息添加学生
    public Integer addStudent(StudentVO studentVO) {
        return addStudentMapper.addStudent(studentVO);
    }

    @Override //  班级人数+1
    public Integer selecteClassinfo(Integer classid) {
        return addStudentMapper.selecteClassinfo(classid);
    }

    @Override   //  年级人数+1
    public Integer selecteGrade(Integer gid) {
        return addStudentMapper.selecteGrade(gid);
    }

    @Override  //  专业人数+1
    public Integer selecteMajor(Integer mid) {
        return addStudentMapper.selecteMajor(mid);
    }

    @Override   //  系部人数+1
    public Integer selecteDepartment(Integer did) {
        return addStudentMapper.selecteDepartment(did);
    }

    @Override   // 查询所有学生
    public List<Map> selStudent(StudentVO studentVO) {
        Map<String,Object> map = new HashMap<>();
        map.put("stuid",studentVO.getStuid());
        map.put("sname",studentVO.getSname());
        map.put("did",studentVO.getDid());
        map.put("mid",studentVO.getMid());
        map.put("gid",studentVO.getGid());
        map.put("classid",studentVO.getClassid());
        return studentMapper.selStudent(map);
    }

    @Override //根据id查询一条学生信息
    public StudentDB selStudentId(Integer id) {
        return studentMapper.selStudentId(id);
    }

    @Override //查询班级
    public List<ClassinfoDB> selClass() {
        return studentMapper.selClass();
    }

    @Override //  修改学生信息
    public int updateStudent(StudentDB studentDB) {
        return studentMapper.updateStudent(studentDB);
    }

    @Override //查询退学信息
    public List<DropoutVO> selDropout(DropoutVO dropoutVO) {
        return studentMapper.selDropout(dropoutVO);
    }

    @Override //对指定学生进行退学
    public int studentDropout(DropoutVO dropoutVO) {
        return studentMapper.studentDropout(dropoutVO);
    }

    @Override //添加退学信息
    public int addDropout(DropoutVO dropoutVO) {
        return studentMapper.addDropout(dropoutVO);
    }

    @Override //根据学生名称查询信息
    public StudentDB student(String name) {
        return studentMapper.student(name);
    }
}
